package com.bestescortbedsystem.controller.userorder;

import com.bestescortbedsystem.entity.SesUserFeedback;
import com.bestescortbedsystem.service.UserFeedBackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * ClassName: UserFeedBackController
 * Package: com.bestescortbedsystem.controller.userorder
 *
 * @author: guanzepeng
 * @Date: 2021/3/2 20:52 星期二
 * @Description: 用户报修controller
 */
@RestController
@Slf4j
@Api(tags = "用户报修controller")
@RequestMapping("/feedback")
public class UserFeedBackController {

	@Resource
	private UserFeedBackService userFeedBackService;

	/**
	 * 根据传入信息添加报修反馈
	 * @param sesUserFeedback 传入SesUserFeedback
	 * @param bedmessageId 传入床位信息表ID
	 * @return 返回Boolean
	 */
	@PostMapping("/insertfeed")
	@ApiOperation(value = "根据传入信息添加报修反馈", response = Boolean.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "bedmessageId", value = "传入床位信息表ID", required = true, dataTypeClass = Long.class)
	})
	public Boolean insertFeed(HttpSession session, SesUserFeedback sesUserFeedback,  Long bedmessageId) {
		String userId = (String) session.getAttribute("userId");
		if (userId == null) {
			return false;
		}
		Boolean b = userFeedBackService.insertFeed(sesUserFeedback, Long.valueOf(userId), bedmessageId);
		return b;
	}
}
